<div class="subheader" id="list-header">
  <div class="fixed-container">
    <div class="btn-group pull-right">
      <button class="btn btn-default" ng-click="createApp()" translate type="button">APPS-LIST.ACTION.CREATE</button>
      <button class="btn btn-default" ng-click="importAppDefinition()" translate type="button">APPS-LIST.ACTION.IMPORT
      </button>
    </div>
    <h2>{{'APPS-LIST.TITLE' | translate}}</h2>
  </div>
</div>
<div auto-height class="container-fluid content" offset="40">
  <div class="col-xs-2 filter-wrapper">
    <div class="input-group">
                <span class="input-group-addon"> <i
                        class="glyphicon glyphicon-search"></i>
                </span> <input class="form-control" ng-change="filterDelayed()" ng-model="model.pendingFilterText"
                               placeholder="{{'APPS-LIST.SEARCH-PLACEHOLDER' | translate}}"
                               type="text">
    </div>
    <ul class="filter-list">
      <li ng-class="{'current' : filter.id == model.activeFilter.id}" ng-repeat="filter in model.filters">
        <a ng-click="activateFilter(filter)">{{'APPS-LIST.FILTER.' + filter.labelKey | translate}}</a>
      </li>
    </ul>
  </div>

  <div class="col-xs-10 item-wrapper" id="list-items">
    <div class="dropdown-subtle pull-right" ng-show="model.apps.size != 0">
      <div activiti-fix-dropdown-bug class="btn-group btn-group-sm">
        <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                type="button">{{'FORMS-LIST.SORT.' + model.activeSort.labelKey | translate}} <i
                class="caret"></i></button>
        <ul class="dropdown-menu pull-right">
          <li ng-repeat="sort in model.sorts">
            <a ng-click="activateSort(sort)">{{'APPS-LIST.SORT.' + sort.labelKey | translate}}</a>
          </li>
        </ul>
      </div>
    </div>
    <div class="message clearfix">
      <div class="loading pull-left" ng-show="model.loading">
        <div class="l1"></div>
        <div class="l2"></div>
        <div class="l2"></div>
      </div>
      <div ng-if="!model.loading">
        <span ng-if="model.apps.size > 1">{{'APPS-LIST.FILTER.' + model.activeFilter.labelKey + '-COUNT' | translate:model.apps}}</span>
        <span ng-if="model.apps.size == 1">{{'APPS-LIST.FILTER.' + model.activeFilter.labelKey + '-ONE' | translate}}</span>
        <span ng-if="model.apps.size == 0 && (!model.filterText || model.filterText == '') &&  model.activeFilter.id != 'myApps'">{{'APPS-LIST.FILTER.' + model.activeFilter.labelKey + '-EMPTY' | translate}}</span>
        <span ng-if="model.apps.size > 0 && model.filterText !='' && model.filterText !== undefined">{{'APPS-LIST.FILTER.FILTER-TEXT' | translate:model}}</span>
        <span ng-if="model.apps.size == 0 && model.filterText !='' && model.filterText !== undefined">{{'APPS-LIST.FILTER.FILTER-TEXT-EMPTY' | translate:model}}</span>

      </div>
    </div>

    <div class="help-container fixed"
         ng-if="model.apps.size == 0 && !model.loading && model.activeFilter.id == 'myApps' &&  (!model.filterText || model.filterText == '')">
      <div>
        <div class="help-text wide">
          <div class="description">
            {{'APPS-LIST.FILTER.NO-APPS' | translate}}
          </div>
          <div class="help-entry" ng-click="createApp()">
            <span class="glyphicon glyphicon-plus-sign"></span>
            <span translate="APPS-LIST.FILTER.NO-APPS-CALL-TO-ACTION"></span>
            <br>
            <span class="note" translate="APPS-LIST.FILTER.NO-APPS-NOTE"></span>
          </div>
        </div>
      </div>
    </div>

    <div class="item fadein" ng-repeat="app in model.apps.data">
      <div class="app {{app.appDefinition.theme ? app.appDefinition.theme : 'theme-1'}}">
        <div class="app-actions">
          <span class="badge">v{{app.version}}</span>
          <div class="btn-group pull-right">
            <button class="btn btn-default" ng-click="showAppDetails(app); $event.stopPropagation();"
                    title="{{'APP.ACTION.DETAILS' | translate}}"
                    type="button">
              <i class="glyphicon glyphicon-search"></i>
            </button>
            <button class="btn btn-default" ng-click="editAppDetails(app); $event.stopPropagation();"
                    title="{{'APP.ACTION.OPEN-IN-EDITOR' | translate}}"
                    type="button">
              <i class="glyphicon glyphicon-edit"></i>
            </button>
          </div>
        </div>
        <a ng-click="showAppDetails(app)">
          <div class="app-content">
            <h3>{{app.name}}</h3>

            <p>{{app.description}}</p>
          </div>
          <div class="backdrop">
            <i class="icon icon-choice" ng-show="!app.appDefinition.icon"></i>
            <i class="glyphicon {{app.appDefinition.icon}}" ng-show="app.appDefinition.icon"></i>
          </div>
          <div class="logo">
            <i class="icon icon-choice" ng-show="!app.appDefinition.icon"></i>
            <i class="glyphicon {{app.appDefinition.icon}}" ng-show="app.appDefinition.icon"></i>
          </div>
        </a>
      </div>
    </div>

    <div class="show-more" ng-if="model.apps.data.length < model.apps.total">
      <a>{{'APPS-LIST.ACTION.SHOW-MORE' | translate}}</a>
    </div>
  </div>
</div>
